package com.hubu.parking.model.enums;

import lombok.Getter;
import org.apache.commons.lang3.ObjectUtils;

/**
 * 车位状态枚举
 */
public enum LogicStatusEnum {

    UN_AVAILABLE(0, "逻辑否"),
    AVAILABLE(1, "逻辑是"),
    ;

    @Getter
    private final Integer value;

    @Getter
    private final String desc;

    LogicStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static LogicStatusEnum getEnumByValue(Integer value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (LogicStatusEnum anEnum : LogicStatusEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

}
